package org.kumas.sgrpc.remoting;

import java.io.IOException;

import org.kumas.sgrpc.common.extension.Adaptive;
import org.kumas.sgrpc.common.extension.SPI;
import org.kumas.sgrpc.remoting.buffer.ChannelBuffer;

/**
 *
 * @author KumasZhang
 * @version 1.0
 * @since 2021-07-15 08:22
 */
@SPI
public interface Codec {
    @Adaptive({Constants.CODEC_KEY})
    void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException;

    @Adaptive({Constants.CODEC_KEY})
    Object decode(Channel channel, ChannelBuffer buffer) throws IOException;


    enum DecodeResult {
        NEED_MORE_INPUT, SKIP_SOME_INPUT
    }
}
